package com.capgemini.scaffold.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.capgemini.scaffold.common.ResponseBean;
import com.capgemini.scaffold.dto.FrontDTO;
import com.capgemini.scaffold.entity.Front;
import com.capgemini.scaffold.mapper.FrontMapper;
import com.capgemini.scaffold.service.FrontService;
import com.capgemini.scaffold.utils.UserHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 实习生前端成绩controller类
 */
@Api("实习生前端成绩")
@RestController
@RequestMapping("/front")
public class FrontController {

    @Autowired
    FrontService frontService;
    @Resource
    private FrontMapper frontMapper;

    @ApiOperation("实习生成绩模糊查询接口")
    @PostMapping("/queryFront")
    public ResponseBean<List<Front>> queryUser(@RequestBody FrontDTO req) {
        return ResponseBean.success(frontService.queryFront(req));
    }

    @ApiOperation("分页查询用户信息")
    @PostMapping("/queryFrontPage")
    public ResponseBean<IPage<Front>> queryUserPage(@RequestBody FrontDTO req) {
        return ResponseBean.success(frontService.findFrontPage(req));
    }
    @ApiOperation("删除实习生成绩信息")
    @DeleteMapping("/{id}")
    public ResponseBean<Front> delFrontById(@PathVariable("id") Integer id){
        return ResponseBean.success(frontMapper.deleteById(id));
    }

    @ApiOperation("修改实习生成绩信息")
    @PutMapping
    public ResponseBean<Front> updataFront(@RequestBody Front front){
        return ResponseBean.success(frontMapper.updateById(front));
    }


    @ApiOperation("插入实习生成绩信息")
    @PostMapping
    public ResponseBean<Front> insertFront(@RequestBody Front front){
        return ResponseBean.success(frontMapper.insert(front));
    }
}
